package com.xiaoqiudong.forum.controller;


import com.xiaoqiudong.forum.common.AppResult;
import com.xiaoqiudong.forum.exception.ApplicationException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA
 * Descroption
 * User:dell
 * Date:2025-08-20
 * Time:19:12
 */
@RestController
@RequestMapping("/test")
@Tag(name = "测试的接口")
public class TestController {
    @Operation(summary = "测试接口1，显示hello")
    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }
    @Operation(summary = "测试接口2，显示抛出Exception的异常星系")
    @GetMapping("/exception")
    public AppResult testException() throws Exception{
        throw  new Exception("这是一个exception");
    }

    @Operation(summary = "测试接口3，显示抛出applicationException的异常星系")
    @GetMapping("/applicationException")
    public AppResult applicationException(){
        throw new ApplicationException("这是一个applicationException");
    }
    @Operation(summary = "测试接口4，按传入姓名显示你好消息")
    @PostMapping("/helloByName")
    public String helloByName(@RequestParam("name") String name){
        return "hello: "+name;
    }
}
